$(".register").find("li").click(function(){
    var d = $("<div class='angle'></div>")
    $(this).append(d).siblings().children("div").remove();
    $(this).addClass("active").siblings().removeClass("active");
    $(".cont").children("div").css("display","none").eq($(this).index()).css("display","block");

})
class Register{
    constructor(){
        // 选择各种元素
        this.pho = document.querySelector(".pho");
        this.cod = document.querySelector(".cod");
        this.ema = document.querySelector(".ema");
        this.pas = document.querySelector(".pas");
        this.submit = document.getElementById("submit2");
        this.msg = document.querySelector(".msg");
        // 提前准备接口
        this.url = "http://api.icodeilife.cn:81/user";
        // 绑定事件
        this.addEvent()
    }
    addEvent(){
        var that = this;
        this.submit.onclick = function(){
            // that.p = that.pho.value;
            // that.c = that.cod.value;
            that.e = that.ema.value;
            that.p2 = that.pas.value;
            that.load();
        }
    }
    load(){
        ajax({
            url:this.url,
            data:{      
                type: "register",
                user: this.e,
                pass: this.p2,
            }
        }).then((res)=>{
            console.log(res);
            this.res = JSON.parse(res);
            this.display();
        })
    }
    display(){
        if(this.res.code == 1){
            this.msg.innerHTML = this.res.msg + "，3秒后到登录页面";
            setTimeout(()=>{
                location.href = "login.html";
            },3000);
        }else{
            this.msg.innerHTML = this.res.msg;
        }
    }
}

new Register;